package top.bug.blog.enums;

import lombok.Getter;

/**
 * @author <a href="https://github.com/jiusi66">九思.</a>
 * @email 10837907@qq.com
 * @from <a href="https://www.52bug.top">递归茶馆-www.52bug.top</a>
 * @description 点赞操作枚举
 */
@Getter
public enum LikeEnum {

    /**
     * 文章点赞
     */
    ARTICLE_LIKE_PREFIX("0", "ARTICLE:"),

    /**
     * 评论点赞
     */
    COMMENTS_LIKE_PREFIX("1", "COMMENTS:");


    /**
     * 点赞类型
     */
    final String likeType;

    /**
     * 点赞缓存键前缀
     */
    final String keyPrefix;

    LikeEnum(String likeType, String keyPrefix) {
        this.likeType = likeType;
        this.keyPrefix = keyPrefix;
    }

    /**
     * 根据点赞类型获取对应的缓存键前缀
     */
    public static String getKeyPrefix(String likeType) {
        for (LikeEnum value : LikeEnum.values()) {
            if (value.likeType.equals(likeType)) {
                return value.keyPrefix;
            }
        }
        return null;
    }

}
